<template>
	<view class="screen_box">
		<view class="account_box">
			<view class="account_item" v-if="display">
				<view class="account_list" v-for="(item,index) in data" :key="index">
					<view class="account_cont">
						<image :src="'/static/balanceType/balance' + item.balance_type_id + '.png'" mode=""></image>
						<view class="" style="width: 100%;">
							<view class="increase">
								<text>{{item.mome}}</text>
								<text v-if="item.earn_type == 1" class="green-txt">+{{item.money}}</text>
								<text v-else class="red-txt">-{{item.money}}</text>
							</view>
							<view v-if="item.product_name" class="msg" style="font-size: 24rpx; color: #c8c9cc; padding-bottom: 10rpx;">
								{{item.product_name}}
							</view>
							<u--text :text="item.create_time" color="#999999" align="left" size="24rpx"></u--text>
						</view>
					</view>
				</view>
			</view>
			<u-empty v-else mode="list" icon="/static/Empty/data_null.png"></u-empty>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				data: [],
				page: 1,
				start_time: null,
				end_time: null,
				screen_show: false,
				bottom: true,
				display: false,
				proid: null,
				isChg: null,
				typs: null,
				userinfo: {},
				dayTyps: ''
			}
		},
		//上拉加载
		onReachBottom() {
			if (this.bottom == true) {
				this.page += 1
				this._request()
			}
		},
		onLoad(e) {
			this.userinfo = uni.getStorageSync('userinfo');
			uni.pageScrollTo({
				scrollTop: this.scrollTop
			});
			this.proid = e.pid
			this.isChg = e.isChg
			this.typs = e.typs
			this.start_time = e.dates
			this.end_time = e.dates
			this.dayTyps = e.dayTyps
			uni.setNavigationBarTitle({
				title: e.name + ' - 明细'
			})
			this._request()
		},
		methods: {
			async _request() {
				uni.showLoading({
					title: '加载中'
				});
				const {
					data: res
				} = await this.$myHttp5({
					url: 'Datas/accout_typs_details',
					data: {
						typs: this.typs,
						isChg: this.isChg,
						proid: this.proid,
						page: this.page,
						page_size: 15,
						date: this.start_time,
						dayTyps: this.dayTyps
					},
					header: {
						'token': this.userinfo.token
					},
				});
				uni.hideLoading()
				if (res.code == 1) {
					if (this.search_type) {
						if (res.data.data !== undefined && res.data.data !== null && res.data.data.length >
							0) {
							this.display = true
							if (this.page == 1) {
								this.data = res.data.data

							} else {
								this.data = [...this.data, ...res.data.data]
							}
						} else {
							this.bottom = false
							this.display = false
							if (this.page > 1) {
								this.display = true
							}
						}
					} else {
						if (res.data.data !== undefined && res.data.data !== null && res.data.data.length >
							0) {
							this.display = true
							if (this.page == 1) {
								this.data = res.data.data
							} else {
								this.data = [...this.data, ...res.data.data]
							}
						} else {
							this.bottom = false
							this.display = false
							if (this.page > 1) {
								this.display = true
							}
						}
					}
				} else {
					uni.showToast({
						title: res.msg,
						duration: 1000,
						icon: "none"
					});
					this.bottom = false
					this.display = false
				}
			},
			info() {
				uni.navigateTo({
					url: '/pages/version5/mine/account/account_info?id=' + this.tab[this.current].balance_type_id
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	page {
		background-color: #f3f4f6;
	}
	
	.screen_box {
		padding: 30rpx;
		box-sizing: border-box;

		.screen_option {
			display: flex;
			flex-wrap: wrap;
			align-items: center;
			// justify-content: space-between;
			margin: 30rpx 0;

			text {
				background-color: #eee;
				border: #eee 1px solid;
				padding: 10rpx 20rpx;
				color: #333;
				border-radius: 15rpx;
				display: flex;
				align-items: center;
				justify-content: center;
				margin: 0 5rpx 30rpx 5rpx;
			}

			text.on {
				background-color: #eee;
				border: #55aaff 1px solid;
				padding: 10rpx 20rpx;
				color: #55aaff;
				border-radius: 15rpx;
				display: flex;
				align-items: center;
				justify-content: center;
			}

			.datetime {
				margin: 0;
			}
		}
	}

	.btn {
		display: flex;
		align-items: center;
		justify-content: center;

		text {
			width: 100%;
			padding: 30rpx 0;
			text-align: center;
			background-color: #55aaff;
			color: #fff;
		}
	}

	.balance {
		display: flex;
		flex-direction: column-reverse;
		padding: 30rpx;
		box-sizing: border-box;
		margin-bottom: 30rpx;

		.balance_top {
			display: flex;
			justify-content: space-between;
			// flex-direction: column;
			// align-items: center;
			width: 100%;

			text {
				font-size: 28rpx;
				color: #666666;
			}

			h2 {
				font-weight: 500;
				margin-top: 10rpx;
				margin-bottom: 30rpx;
				font-size: 42rpx;
			}
		}


		.expenses {
			display: flex;
			margin-bottom: 30rpx;
			box-sizing: border-box;
			align-items: center;
			justify-content: center;

			.dbs {
				// width: 100%;
			}

			.expenses_time {
				display: flex;
				justify-content: flex-start;
				align-items: center;

				.order {
					color: #fff;
					font-size: 28rpx;
					padding: 5rpx 20rpx;
					background-color: #1e80ff;
					border-radius: 15rpx;
					margin-left: 50rpx;
				}
			}

			text {
				font-size: 24rpx;
				color: #999999;
			}
		}
	}

	.account_box {
		padding-bottom: 20rpx;
		.account_list {
			padding: 25rpx;
			display: flex;
			justify-content: space-between;
			align-items: center;
			margin-bottom: 20rpx;
			background-color: #fff;
			border-radius: 15rpx;
			box-shadow: 7px 0px 30px -18px #888888;

			.account_cont {
				display: flex;
				align-items: center;
				width: 100%;

				image {
					width: 60rpx;
					height: 55rpx;
					margin-right: 20rpx;
				}

				text {
					color: #999;
					font-size: 24rpx;
					// margin-bottom: 20rpx;
				}
			}

			.increase {
				display: flex;
				justify-content: space-between;
				font-size: 24rpx;
				margin-bottom: 10rpx;
				width: 100%;

				text {
					color: #333;
					font-size: 28rpx;
				}

				.green-txt {
					color: #19be6b;
				}
				
				.red-txt {
					color: #fa3534;
				}
			}
		}

		.account_list:last-child {
			border-bottom: none;
		}
	}
</style>